package experiment.e03.code;

/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/9/29 15:41
 * @package experiment.e03.code
 * @description 文件说明 回文
 */

public class E02_Compare {
    public static void main(String[] args) {
        String str1 = "good44";
        String str2 = "good";

        int minLength = Math.min(str1.length(), str2.length());

        // 切割字符串
        for (int i = 0; i < minLength; i++) {
            // 比较每一个位置上的字符的ASCII 码值
           if (str1.charAt(i) < str2.charAt(i)){
               System.out.println("较小的元素是：" +str1);
               System.exit(0);
           }else if (str1.charAt(i) > str2.charAt(i)){
               System.out.println("较小的元素是：" +str2);
               System.exit(0);
           }
        }

        if(str1.length() < str2.length()){
            System.out.println("较小的元素：" +str1);
        }else {
            System.out.println("较小的元素：" +str2);
        }

    }
}
